//区县分项目人数，金额
var myChart2 = echarts.init(document.getElementById('map3-a'));

var xAxis_LeftBottom= [];
var data1_CenterBottom= [];
var data2_CenterBottom= [];
var Arr_centerBottom,parad,yearNum=0;
var Obj_centerBottom=[];
var res=[];
var series=[];
var setTop=7;
var setSize_leftBottom=16,yAxisSizeLast=16;
var option2 = {
    color: ['#3398DB','red'],
    title: {
    },
     grid: {
        left: '10%',
        right: '5%',
        bottom: '5%',
        containLabel: true,
        show:false,
        // backgroundColor:'rgba(128, 128, 128, 0.5)'
    },
        tooltip : {
            trigger: 'axis',
            axisPointer: {
                crossStyle: {
                    color: '#999'
                }
            },
            position:'left',
            formatter:(params) => {
                // console.log(params)
                /*+"地理坐标:[" + params.value[0]+","+params.value[1] +"]"*/
                let data = "<div class='leftCenter_hover'>"+
                "<p>项目名称:"+params[0].axisValue + "</p>"+
                "<p>项目人均:"+ params[0].value+"元"+"</p>"+
                "</div>";
			   return data;
			}
    },
    dataZoom: [{
        type: 'inside',
        show:false,
        start: 0,
        end: 100
    }

],
   
    xAxis: [
        {
            axisLabel:{
            	show:true,
                interval : 0, 
                textStyle: {
                    color: '#fff'
                },
                fontSize:setSize_leftBottom,
            },
            splitLine: {
                show: false
            },
            type: 'category',
            data: [],
            axisPointer: {
                type: 'shadow',
                alignWithLabel: true
            },
            nameTextStyle:{
                color:"#fff"
            },
            
        }
        
    ],
    yAxis: [
        {
            splitLine: {
                show: true,
                lineStyle:{
                    opacity:0.5
                },
            },
            type: 'value',
            nameTextStyle:{
                color:"#fff"
            },
            color:"#fff",
            min: 0,
            axisLabel: {
        		show:true,
                formatter: '{value}',
                color: '#fff',
                fontSize:yAxisSizeLast
            }
        }
    ],
    series: 
    [
    ]
}
//地区图
var option3 = {
    color: ['#3398DB','red'],
    title: {
    },
     grid: {
        left: '10%',
        right: '5%',
        bottom: '5%',
        containLabel: true,
        show:false,
        // backgroundColor:'rgba(128, 128, 128, 0.5)'
    },
        tooltip : {
            trigger: 'axis',
            axisPointer: {
                crossStyle: {
                    color: '#999'
                }
            },
            position:'left',
            formatter:(params) => {
                // console.log(params)
                // "项目名:"+ params[0].data.ar+"<br/>+"
                let data = "<div class='leftCenter_hover'>"+
                "<p>项目名称:"+params[0].axisValue + "</p>"+
                "<p>项目人均:"+ params[0].value+"元"+"</p>"+
                "</div>";
            return data;
            },
//formatter:'{b}{c}{a}'
    },
    dataZoom: [{
        type: 'inside',
        show:false,
        start: 0,
        end: 100
    }
],
   
    xAxis: [
        {
            axisLabel:{
            	show:true,
                interval : 0, 
                textStyle: {
                    color: '#fff'
                },
                fontSize:setSize_leftBottom,
            },
            splitLine: {
                show: false
            },
            type: 'category',
            data: [],
            axisPointer: {
                type: 'shadow',
                alignWithLabel: true
            },
            nameTextStyle:{
                color:"#fff"
            },
            
        }
        
    ],
    yAxis: [
        {
            splitLine: {
                show: true,
                lineStyle:{
                    opacity:0.5
                },
            },
            type: 'value',
            nameTextStyle:{
                color:"#fff"
            },
            color:"#fff",
            min: 0,
            axisLabel: {
        		show:true,
                formatter: '{value}',
                color: '#fff',
                fontSize:yAxisSizeLast,
            }
        }
    ],
    series: []
}
//项目图
var option4 = {
    color: ['#3398DB','red'],
    title: {
    },
     grid: {
        left: '10%',
        right: '5%',
        bottom: '5%',
        // backgroundColor:'rgba(128, 128, 128, 0.5)',
        show:false,
        containLabel: true
    },
        tooltip : {
            trigger: 'axis',
            axisPointer: {
                crossStyle: {
                    color: '#999'
                }
            },
            position:'left',
            formatter:(params) => {
                // console.log(params)
                // "项目名:"+ params[0].data.ar+"<br/>+"
                let data = "<div class='leftCenter_hover'>"+
                "<p>项目名称:"+params[0].axisValue + "</p>"+
                "<p>项目人均:"+ params[0].value+"元"+"</p>"+
                "</div>";
			   return data;
			}
    },
    dataZoom: [{
        type: 'inside',
        show:false,
        start: 0,
        end: 100
    }
],
   
    xAxis: [
        {
            axisLabel:{
            	show:true,
                interval : 0, 
                textStyle: {
                    color: '#fff'
                },
                fontSize:setSize_leftBottom,
                // formatter:'{category}'
            },
            splitLine: {
                show: false
            },
            type: 'category',
            data: [],
            axisPointer: {
                type: 'shadow',
                alignWithLabel: true
            },
            nameTextStyle:{
                color:"#fff"
            },
            
        }
        
    ],
    yAxis: [
        {
            splitLine: {
                show: true,
                lineStyle:{
                    opacity:0.5
                },
            },
            type: 'value',
//          name: '人数(万人)',
            nameTextStyle:{
                color:"#fff"
            },
            color:"#fff",
            min: 0,
//          interval: 2,
            axisLabel: {
        		show:true,
                formatter: '{value}',
                color: '#fff',
                fontSize:yAxisSizeLast,
            }
        }
    ],
    series: 
    []
}

 function functionTitle(dataCounty){
     var titelName=dataCounty.title;
     return titelName;
 }
 //登入
 startLeftBottom();
function startLeftBottom(){
    $.ajax({
        type: "POST",
        url: baseurl+"county/avlAllList",
        contentType:'application/json',
        // data:leftBottomParam,
        success: function (data) {
            // console.log(data)
            Arr_centerBottom = data 
            Obj_centerBottom =[];
            res = [],xAxis_LeftBottom=[];
    var convertData = function (pdata,pname,parea,j) {
        // console.log(pdata,pname,parea)
            
            res.push({
                        name: pname,
                        value: parseInt(pdata),
                        ar:parea
                    });
    //		
    //		res.name.push(pname)
    //		res.value.push(pdata)
    //		res.ar.push(parea)
    		//  console.log(res)
             if(j=4){
                 
                 parad=res
             }
            return res;
        };
        Arr_centerBottom.length > setTop-1 ? yearNum = setTop : yearNum = Arr_centerBottom.length ;
        for (var j = 0; j < yearNum; j++) {
            convertData(Arr_centerBottom[j].avl_caption,Arr_centerBottom[j].county,Arr_centerBottom[j].project_id,j)	
            xAxis_LeftBottom.push(Arr_centerBottom[j].county)
            }
            series=[];
    //      for (var i=0;i<5;i++) {
                
                  series.push({
                        itemStyle: {
                    normal: {
                        color: new echarts.graphic.LinearGradient(
                            0, 0, 0, 1,
                            [
                                {offset: 0, color: '#e6cd99'},
                                {offset: 0.5, color: '#e6cd99'},
                                {offset: 1, color: '#e6cd99'}
                            ]
                        )
                    },
                    emphasis: {
                        color: new echarts.graphic.LinearGradient(
                            0, 0, 0, 1,
                            [
                                {offset: 0, color: '#e6cd99'},
                                {offset: 0.7, color: '#e6cd99'},
                                {offset: 1, color: '#e6cd99'}
                            ]
                        )
                    }
                },
                      name:'项目人均金额',
                    type:'bar',
                    barWidth:30,
                    barCategoryGap:'20%',
                    data:parad
                  })
            option2.xAxis[0].data = xAxis_LeftBottom;
            // console.log(series[0].dat    a)
            option2.series=series;
            myChart2.hideLoading();
            myChart2.setOption(option2);
            myChart2.setOption({
                xAxis:[{
                        axisLabel:{
                            fontSize:setSize_leftBottom,
                            formatter:function(params){
                                var xAxis_length=parseInt(params.length/2);
                                if(xAxis_length>=3){
                                    var xAxis_name=''+params.substring(0,xAxis_length)+'\n'+params.substring(xAxis_length,params.length)+'';
                                }else{
                                    var xAxis_name=params;
                                }
                                return xAxis_name;
                            }
                        },
                    
                }],
                yAxis:[{
                    axisLabel:{
                        fontSize:yAxisSizeLast
                    }
                }]
            });
        }
    });
}
//点击地区
function LeftBottomZone(zoneLeftBottom){
    $.ajax({
        type: "POST",
        url: baseurl+"county/topCountyList",
        data:zoneLeftBottom,
        contentType:'application/json',
        dataType:"json",
        success: function (data) {
            console.log(data);
            Arr_centerBottom = data 
            Obj_centerBottom =[];
            res = [],xAxis_LeftBottom=[];
            var convertData = function (pdata,pname,parea,j) {
                    res.push({
                                name: pname,
                                value: parseInt(pdata),
                                ar:parea
                            });
                     if(j=4){
                         
                         parad=res
                     }
                    return res;
                };
                Arr_centerBottom.length > setTop-1 ? yearNum = setTop : yearNum = Arr_centerBottom.length ;
                for (var j = 0; j < yearNum; j++) {
                    convertData(Arr_centerBottom[j].avl_caption,Arr_centerBottom[j].county,Arr_centerBottom[j].project_id,j)	
                    xAxis_LeftBottom.push(Arr_centerBottom[j].project_id)
                    }
                    series=[];
                          series.push({
                        temStyle: {
                            normal: {
                                color: new echarts.graphic.LinearGradient(
                                    0, 0, 0, 1,
                                    [
                                        {offset: 0, color: '#e6cd99'},
                                        {offset: 0.5, color: '#e6cd99'},
                                        {offset: 1, color: '#e6cd99'}
                                    ]
                                )
                            },
                            emphasis: {
                                color: new echarts.graphic.LinearGradient(
                                    0, 0, 0, 1,
                                    [
                                        {offset: 0, color: '#e6cd99'},
                                        {offset: 0.7, color: '#e6cd99'},
                                        {offset: 1, color: '#e6cd99'}
                                    ]
                                )
                            }
                        },
                            name:'项目人均金额',
                            type:'bar',
                            barWidth:20,
                            barCategoryGap:'20%',
                            data:parad
                          })
            option3.xAxis[0].data = xAxis_LeftBottom;
            option3.series=series;
            myChart2.setOption(option3);
            myChart2.hideLoading();
            myChart2.setOption({
                xAxis:[{
                        axisLabel:{
                            fontSize:setSize_leftBottom,
                        },
                }],
                yAxis:[{
                    axisLabel:{
                        fontSize:yAxisSizeLast
                    }
                }]
            });
            //     myChart2.setOption({
            //         xAxis:[{
            //             data:xAxis_LeftBottom
            //         }],
            //         tooltip : {
            //             formatter:(params) => {
            //                 // console.log(params)
            //                 // "项目名:"+ params[0].data.ar+"<br/>+"
            //                 let data = "项目名称:"+params[0].axisValue + "<br/>"+"项目人均:"+ params[0].value+"元"+"<br/>"/*+"地理坐标:[" + params.value[0]+","+params.value[1] +"]"*/;
            //             return data;
            //         },
            //     }
            // })
        }
    })
}
//点击项目
function leftbottomPro(proLeftBottom){
    $.ajax({
        type: "POST",
        url: baseurl+"county/topProjectList",
        data:proLeftBottom,
        contentType:'application/json',
        dataType:"json",
        success: function (data) {
            console.log(data)
            Arr_centerBottom = data 
            Obj_centerBottom =[];
        res = [],xAxis_LeftBottom=[];
    var convertData = function (pdata,pname,parea,j) {
        // console.log(pdata,pname,parea)
            
            res.push({
                        name: pname,
                        value: parseInt(pdata),
                        ar:parea
                    });
    //		
    //		res.name.push(pname)
    //		res.value.push(pdata)
    //		res.ar.push(parea)
    //		 console.log(res)
             if(j=4){
                 
                 parad=res
             }
            return res;
        };
        Arr_centerBottom.length > setTop-1 ? yearNum = setTop : yearNum = Arr_centerBottom.length ;
        for (var j = 0; j < yearNum; j++) {
            convertData(Arr_centerBottom[j].avl_caption,Arr_centerBottom[j].county,Arr_centerBottom[j].project_id,j)	
            xAxis_LeftBottom.push(Arr_centerBottom[j].county)
            }
            series=[];
    //      for (var i=0;i<5;i++) {
                
                  series.push({
                        itemStyle: {
                    normal: {
                        color: new echarts.graphic.LinearGradient(
                            0, 0, 0, 1,
                            [
                                {offset: 0, color: '#e6cd99'},
                                {offset: 0.5, color: '#e6cd99'},
                                {offset: 1, color: '#e6cd99'}
                            ]
                        )
                    },
                    emphasis: {
                        color: new echarts.graphic.LinearGradient(
                            0, 0, 0, 1,
                            [
                                {offset: 0, color: '#e6cd99'},
                                {offset: 0.7, color: '#e6cd99'},
                                {offset: 1, color: '#e6cd99'}
                            ]
                        )
                    }
                },
                      name:'项目人均金额',
                    type:'bar',
                    barWidth:20,
                    barCategoryGap:'20%',
                    data:parad
                  })
            option4.xAxis[0].data = xAxis_LeftBottom;
            // console.log(series[0].data)
            option4.series=series;
            myChart2.setOption(option4);
            myChart2.hideLoading();
            myChart2.setOption({
                xAxis:[{
                        axisLabel:{
                            fontSize:setSize_leftBottom,
                        },
                }],
                yAxis:[{
                    axisLabel:{
                        fontSize:yAxisSizeLast
                    }
                }]
            });
        }
    });
}